<template>
  <div class="Refer">
    <div v-if="this.leavel < 1 " class="zhezhao">
      <div class="tishi">当前会员等级不够，需要满一星会员方可推广用户</div>
    </div>
      <div class="title">
        <span></span>
        <span>推广链接</span>
      </div>
      <div class="myStyle one">
        <span>我的推广链接：</span>
        <input type="text" v-model="message" readonly :style='{opacity:this.leavel>=1?"1":"0"}'>
        <!-- <button>点击复制</button> -->
        <el-button
          class="fuZhi"
          type="warning"
          v-clipboard:copy="message"
          v-clipboard:success="onCopy"
          v-clipboard:error="onError"
        >点击复制</el-button>
      </div>
      <div class="myStyle two">
        <span>我的二维码：</span>
        <div class="imgStyle">
          <img :src='srcUrl' :style='{opacity:this.leavel>=1?"1":"0"}'>
          <br>
          <span>请保存二维码图片保存发送给您的朋友吧！</span>
        </div>
      </div>
  </div>
</template>

<script>
export default {
  created() {
    this.getLink()
  },
  mounted() {
    this.leavel = JSON.parse(localStorage.getItem("userData")).memberLevel;
  },
  data() {
    return {
      srcUrl: u.baseurl + "ChinaCommunity/font/member/getQrCodeInfo",
      message: "",
      leavel: null,
    };
  },

  methods: {
    getLink() {
      u.getLink(data => {
        if (!data && !data.data) return;
        this.message = data.data
      });
    },
    onCopy: function(e) {
      this.$message({
        message: "复制成功",
        type: "success"
      });
    },
    onError: function(e) {
      this.$message({
        message: "复制失败",
        type: "error"
      });
    }
  }
};
</script>

<style lang="less" scoped>

.Refer {
  position: relative;
  height: 100%;
  background: white;
  .title {
    height: 50px;
    line-height: 50px;
    font-size: 16px;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    border-bottom: 1px solid #f4f5f6;
    span:nth-child(1) {
      margin: 0px 10px 0px 20px;
      margin-left: 20px;
      line-height: 50px;
      background: #ffb001;
      width: 5px;
      height: 18px;
      display: inline-block;
    }
  }
  .myStyle {
    margin-top: 32px;
    padding-left: 30px;
    font-size: 14px;
  }
  .one {
    display: flex;
    align-items: center;
    span{
      min-width: 100px;
    }
    input {
      width: 468px;
      height: 34px;
      margin: 0px 20px 0px 40px;
      padding-left: 10px;
    }
    .fuZhi {
      width: 98px;
      height: 38px;
      background-color: #ffb001;
      color: white;
      border: none;
      border-radius: 0px;
    }
  }
  .two {
    display: flex;
    span{
      min-width: 86px;
    }
    .imgStyle {
      margin-left: 56px;
      img {
        margin-bottom: 16px;
        width: 90px;
        height: 90px;
      }
      span {
        display: inline-block;
        font-size: 12px;
        color: #737373;
        min-width: 230px;
      }
    }
  }
}
.zhezhao{
  position: absolute;
  height: 100%;
  width: 100%;
  background:rgba(0, 0, 0, 0.5);
  .tishi{
    text-align: center;
    margin-top: 20%;
    font-size: 30px;
    font-weight: bold;
  }
}
</style>
